package com.cskaoyan.service.wx;

import com.cskaoyan.bean.mallbean.Brand;
import com.cskaoyan.mapper.mallmapper.BrandMapper;
import com.cskaoyan.vo.wx.WxBrandListVo;
import com.cskaoyan.vo.wx.WxBrandVo;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: feisl
 * @Date: 2021/5/12 20:12
 */
@Service
public class WxBrandServiceImpl implements WxBrandService{
    @Autowired
    BrandMapper brandMapper;
    @Override
    public WxBrandListVo list(Integer page, Integer size) {
//        PageHelper.startPage(page,size);
        List<WxBrandVo> wxBrandVOS = brandMapper.selectBrandListVO((page-1)*size,size);
        PageInfo<WxBrandVo> brandListVOPageInfo = new PageInfo<>(wxBrandVOS);
        long total = brandListVOPageInfo.getSize();
        WxBrandListVo wxBrandListVO = new WxBrandListVo();
        wxBrandListVO.setTotalPages(total);
        wxBrandListVO.setBrandList(wxBrandVOS);
        return wxBrandListVO;
    }

    @Override
    public Brand detail(Integer id) {

        Brand brand = brandMapper.selectByPrimaryKey(id);

        return brand;
    }
}
